import { _decorator, Component, Node, v3, Tween, tween } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LoopScaleAnim')
export class LoopScaleAnim extends Component {

    @property
    time = 1;
    @property
    step = 0.15;

    onEnable() {
        this.showAnim();
    }

    _scale = v3();
    showAnim() {
        Tween.stopAllByTarget(this._scale);
        this._scale.set(1, 1, 1);
        this.node.setScale(this._scale);
        let _s = 1 - this.step;
        tween(this._scale).repeatForever(
            tween(this._scale).to(this.time, { x: _s, y: _s, }).
                to(this.time, { x: 1, y: 1, }).
                start()
        ).start();

    }

    update(dt) {
        this.node.setScale(this._scale);
    }

}

